package com.example.dao.Impl;

import com.example.dao.UserDao;
import com.example.util.JdbcUtil;

import java.sql.ResultSet;


/***
 * 数据库操作中关于用户信息的实现类
 * @return
 */
public class UserDaoImpl implements UserDao {

    /**
     * 用户登录的方法
     * @param userName
     * @param password
     * @return
     */
    @Override
    public ResultSet UserLogin(String userName, String password) {
        String sql ="select * from user where userName=? and password=?";
        Object[] objects = new Object[2];
        objects[0]=userName;
        objects[1]=password;
        ResultSet data = JdbcUtil.getData(sql, objects);
        return data;
    }

    /**
     * 注册用户的方法
     * @param userName
     * @param password
     * @return
     */

    @Override
    public int UserAdd(String userName, String password) {
        String sql="insert into user (userName,password) value (?,?) ";
        Object[] objects = new Object[2];
        objects[0]=userName;objects[1]=password;
        int i = JdbcUtil.CRUData(sql, objects);
        return i;
    }
}
